package com.woniu.springcrud.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: 16327
 * @date: 2021/1/18 15:38
 * @description:
 */
@Configuration
public class CROSConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedMethods("*")   // 允许客户端用任何请求方式发请求
                .allowedHeaders("*")   // 允许客户端携带任意请求头
                .allowCredentials(true)  // 允许客户端携带cookie
                .allowedOrigins("http://localhost:8080");
    }
}
